package com.dream.network;

import java.io.IOException;
import java.io.InputStream;

import okhttp3.Response;

/**
 * Description: TODO
 * author: Wang
 * date: 3/9/17 17:01
 * email:life_artist@163.com
 * Copyright©2017 by wang. All rights reserved.
 */
public class HttpResponse {

    private final Response mResponse;

    public HttpResponse(Response response) {
        mResponse = response;
    }

    public String getString() {
        if (mResponse == null)
            return null;

        try {
            return mResponse.body().string();
        } catch (IOException e) {
        }
        return null;
    }

    public InputStream getByteStream() {
        return (mResponse == null) ? null : mResponse.body().byteStream();
    }

    public long getContentLength() {
        return (mResponse == null) ? 0 : mResponse.body().contentLength();
    }

    public Response getResponse() {
        return mResponse;
    }

}
